﻿#pragma once
#include "ViewModelBase.h"
#include "TitleBarViewModel.g.h"


namespace winrt::NovelReader::implementation
{
    struct TitleBarViewModel : TitleBarViewModelT<TitleBarViewModel, NovelReader::implementation::ViewModelBase>
    {
        TitleBarViewModel();
        winrt::Microsoft::UI::Xaml::Input::ICommand FileOpenCommand();
        winrt::Microsoft::UI::Xaml::Input::ICommand ExitCommand();
        winrt::Microsoft::UI::Xaml::Input::ICommand SetFontSizeCommand();
        winrt::Microsoft::UI::Xaml::Input::ICommand SetFontFamilyCommand();
        winrt::Microsoft::UI::Xaml::Input::ICommand SetReaderThemeCommand();
        winrt::Microsoft::UI::Xaml::Input::ICommand SetWhiteLinesCommand();
        winrt::Microsoft::UI::Xaml::Input::ICommand ChangeScrollDirectionCommand();
        winrt::Microsoft::UI::Xaml::Input::ICommand HideContentsCommand();
        winrt::Microsoft::UI::Xaml::Input::ICommand AutoTurnPageCommand();
        winrt::Microsoft::UI::Xaml::Input::ICommand SetAutoTurnPageSpeed();

        winrt::hstring DisplayTitle();
        void SetDisplayTitle(winrt::hstring const& value);

        winrt::hstring TrunPageMenuItemText(); 
        void TrunPageMenuItemText(winrt::hstring const& value); 

        winrt::Microsoft::UI::Xaml::Visibility HalfTitleVisibility() const;
        void HalfTitleVisibility(winrt::Microsoft::UI::Xaml::Visibility const& value);

        winrt::Microsoft::UI::Xaml::Visibility FullTitleVisibility() const;
        void FullTitleVisibility(winrt::Microsoft::UI::Xaml::Visibility const& value);

        winrt::Microsoft::UI::Xaml::Media::Brush ReadingMenuItemBackground(); 

        winrt::event_token ScrollDirectionChanged(winrt::NovelReader::ScrollDirectionChangedHandler const& handler);
        void ScrollDirectionChanged(winrt::event_token const& token) noexcept;

        winrt::event_token ContentsVisibilityChanged(winrt::NovelReader::VisibilityActionHandler const& handler);
        void ContentsVisibilityChanged(winrt::event_token const& token) noexcept;

        winrt::event_token AutoTurnPageEvent(winrt::NovelReader::BooleanActionHandler const& handler);
        void AutoTurnPageEvent(winrt::event_token const& token) noexcept;

    private:
        winrt::fire_and_forget OnFileOpenCommandInvoked(winrt::Windows::Foundation::IInspectable const& parameter);
        void OnExitCommandInvoked(winrt::Windows::Foundation::IInspectable const& parameter);
        void OnSetFontSizeCommandInvoked(winrt::Windows::Foundation::IInspectable const& parameter);
        void OnSetFontFamilyCommandInvoked(winrt::Windows::Foundation::IInspectable const& parameter);
        void OnSetReaderThemeCommandInvoked(winrt::Windows::Foundation::IInspectable const& parameter);
        void OnSetWhiteLinesCommandInvoked(winrt::Windows::Foundation::IInspectable const& parameter);
        void OnChangeScrollDirectionCommandInvoked(winrt::Windows::Foundation::IInspectable const& parameter);
        void OnHideContentsCommandInvoked(winrt::Windows::Foundation::IInspectable const& parameter);
        void OnAutoTurnPageCommandInvoked(winrt::Windows::Foundation::IInspectable const& parameter);
        void OnSetAutoTurnPageSpeedCommandInvoked(winrt::Windows::Foundation::IInspectable const& parameter); 

        bool CanScrollDirectionCommandInvoked(winrt::Windows::Foundation::IInspectable const& parameter) const; 

        winrt::Microsoft::UI::Xaml::Input::ICommand m_fileOpenCommand{ nullptr };
        winrt::Microsoft::UI::Xaml::Input::ICommand m_exitCommand{ nullptr };
        winrt::Microsoft::UI::Xaml::Input::ICommand m_setFontSizeCommand{ nullptr };
        winrt::Microsoft::UI::Xaml::Input::ICommand m_setFontFamilyCommand{ nullptr };
        winrt::Microsoft::UI::Xaml::Input::ICommand m_setReaderThemeCommand{ nullptr };
        winrt::Microsoft::UI::Xaml::Input::ICommand m_setWhiteLinesCommand{ nullptr };
        winrt::Microsoft::UI::Xaml::Input::ICommand m_changeScrollDirectionCommand{ nullptr };
        winrt::Microsoft::UI::Xaml::Input::ICommand m_hideContentsCommand{ nullptr };
        winrt::Microsoft::UI::Xaml::Input::ICommand m_autoTurnPageCommand{ nullptr };
        winrt::Microsoft::UI::Xaml::Input::ICommand m_setAutoTurnPageSpeedCommand{ nullptr };

        winrt::hstring m_displayTitle;
        winrt::hstring m_autoTurnPageMenuItemText;
        winrt::Microsoft::UI::Xaml::Visibility m_halfTitleVisibility;
        winrt::Microsoft::UI::Xaml::Visibility m_fullTitleVisibility;
        winrt::event<winrt::NovelReader::ScrollDirectionChangedHandler> m_scrollDirectionChanged;
        winrt::event<winrt::NovelReader::VisibilityActionHandler> m_contentVisibilityChanged;
        winrt::event<winrt::NovelReader::BooleanActionHandler> m_autoTrunPageEvent; 
        bool m_enableAutoTurnPage {false}; 
    };
}
namespace winrt::NovelReader::factory_implementation
{
    struct TitleBarViewModel : TitleBarViewModelT<TitleBarViewModel, implementation::TitleBarViewModel>
    {
    };
}
